package org.springblade.modules.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.entity.ElevatorReportConfig;
import org.springblade.modules.admin.entity.MaintainReport;
import org.springblade.modules.admin.entity.MaintainReportSend;
import org.springblade.modules.admin.service.ElevatorReportConfigService;
import org.springblade.modules.admin.service.MaintainReportService;
import org.springframework.web.bind.annotation.*;

import java.sql.Wrapper;
import java.util.HashMap;
import java.util.List;

/**
 * @Date 15:26 2024/7/17
 * @Description {
 *   项目电梯报告配置
 * }
 * @Author lsay
 **/
@AllArgsConstructor
@RestController
@RequestMapping("/elevator/report/config")
public class ElevatorReportConfigController {

	private final ElevatorReportConfigService elevatorReportConfigService;

	/**
	 * @Author lsay
	 * @Description {
	 *   更新项目电梯配置
	 * }
	 * @Date 16:04 2024/7/23
	 * @Param
	 * @return
	 **/
	@PostMapping("/submit")
	public R<Boolean> submit(@RequestBody List<ElevatorReportConfig> entityList){
		return R.data(elevatorReportConfigService.submit(entityList));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   获取项目电梯配置 根据项目分组
	 * }
	 * @Date 16:10 2024/7/23
	 * @Param
	 * @return
	 **/
	@GetMapping("/tree")
	public R<List<ElevatorReportConfig>> tree(){
		return R.data(elevatorReportConfigService.tree(AuthUtil.getTenantId()));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   获取项目电梯配置
	 * }
	 * @Date 16:10 2024/7/23
	 * @Param
	 * @return
	 **/
	@GetMapping("/list")
	public R<List<ElevatorReportConfig>> list(){
		return R.data(elevatorReportConfigService.list(Wrappers.<ElevatorReportConfig>lambdaQuery().eq(ElevatorReportConfig::getTenantId,AuthUtil.getTenantId())));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   批量删除
	 * }
	 * @Date 16:03 2024/7/23
	 * @Param
	 * @return
	 **/
	@PostMapping("/remove")
	public R<Boolean> remove(@RequestBody HashMap<String,String> map){
		return R.data(elevatorReportConfigService.removeByIds(Func.toLongList(String.valueOf(map.get("ids")))));
	}

}
